package com.car.service.listener;

import java.util.List;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

import com.car.entity.Carrentalorderform;
import com.car.mapper.CarrentalorderformMapper;
import com.car.service.CarrentalorderformService;

@Service
public class OrderTimeoutMessageListener {

	@Autowired
	CarrentalorderformMapper carrentalorderformapper;
	
	@JmsListener(destination ="orderTimeout")
	public void onMessage(Message message) {
		// TODO Auto-generated method stub
		TextMessage tm = (TextMessage)message;
		try {
			System.out.println("OrderTimeoutMessageListener监听到了文本消息：\t"+tm.getText());
			//更改數據庫操作
			String orderId = tm.getText().toString();
			Carrentalorderform carr = carrentalorderformapper.selectByOrderIdTolistener(orderId);
			if(carr.getOrderState().equals("3")){
				carrentalorderformapper.updOrderState("6", orderId);
			}
		} catch (JMSException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
